<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>地图导航</title>
</head>
<style>
        *{
            margin:0;
            padding: 0;
        }
        #container{
            width: 100%;
            height: 100vh;
            background-color: white
        }



</style>
<body>
<div id="container"></div>

<script type="text/javascript">
    window._AMapSecurityConfig = {
    	securityJsCode: "70b4ab155c3329b1e1a104da51b49b57",
	}

</script>
<script type="text/javascript"
        src="https://webapi.amap.com/maps?v=1.4.15&key=b1c1edb61adfb7f9cb9405316abc6158"></script>
<script type="text/javascript">
          //地图初始化应该在地图容器div已经添加到DOM树之后
          var map = new AMap.Map("container", {
            zoom: 15,//级别
            center: [121.48500,31.206309],//中心坐标
          });

          /*
          //接收鸿蒙端发送的数据
          var hmPort;
          window.addEventListener("message", function(event){
                //map.setCenter([lng, lat]); //设置地图中心点
               if(event.data == "__init_port__"){
                   hmPort = event.ports[0]
                   hmPort.postMessage(JSON.stringify({type:"connect_ok"}))
               }

          */

          window.onload = function(){
               // window.swift.alert("大家好！")
          }

          function showHtmlMsg(){
              window.swift.toast("我是定义方法")
          }

          function getLocation(lon,lat){
               //window.swift.alert(lon+"."+lat)
               map.setZoomAndCenter(15,[lon,lat])

               map.plugin(['AMap.PlaceSearch'],function(){
                   var PlaceSearchOptions = {
                       pageSize:4,
                       pageIndex:1,
                       extensions:"base"
                   };
                   var MSearch = new AMap.PlaceSearch(PlaceSearchOptions)
                   AMap.event.addListener(MSearch,"complete",(result)=>{
                   //
                   window.swift.receiveData(JSON.stringify(result?.poiList?.pois||[]))
                   })
                   //
                   MSearch.searchNearBy("步行街",new AMap.LngLat(lon,lat))
               })
          }


</script>
</body>

</html>